function traintest()
    addpath('netlab3_3');
    Sets = load('twoclass.mat');
    [Train Test] = combineSets(Sets, 0.75, 0);
    
    %plotting the test and training set
    Aplot = Train(find(Train(:,3)),1:2);
    Bplot = Train(find(Train(:,4)),1:2);    
    plot(Aplot(:,1),Aplot(:,2),'.',Bplot(:,1),Bplot(:,2),'*');
    legend('training data A', 'training data B');
    xlim([-15 15]);
    waitforbuttonpress;
    
    %test different k's 
    for k=1:100,
        classifier = knn(2,2, k, Train(:,1:2), Train(:,3:4));
        [Results Labels] = knnfwd(classifier,Test(:,1:2));
        mat = confmat(Results, Test(:,3:4));
        correct(k) = (mat(1,1) + mat(2,2)) / length(Results);
        false(k) = 1-correct(k);
    end
    
    %plot the error rate over different k's
    plot([1:100], false);
    xlabel('k');
    ylabel('error value');
end